package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.security.Key;

/**
 * 接受登录状态存入Rdies缓存后续操作
 */

@RestController
@RequestMapping("/admin/shop")
public class ShopController {

    //设置Rdies缓存键
    public static final String KEY = "SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("获取店铺的营业状态")
    @PutMapping("/{status}")
    public Result getStatus(@PathVariable Integer status) {

        redisTemplate.opsForValue().set(KEY, status);

        return Result.success();
    }

    @ApiOperation("设置店铺的营业状态")
    @GetMapping("/status")
    public Result setStatus() {

        Integer o = (Integer) redisTemplate.opsForValue().get(KEY);

        return Result.success(o);

    }


}
